package com.mes.device.controller;

import com.mes.common.pojo.MESResult;
import com.mes.device.server.DeviceTypeServer;
import com.mes.pojo.device.DeviceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 张喆
 * @Company
 * @Description
 * @Time 2024/10/16 17:02
 */
@RestController
@CrossOrigin
@RequestMapping("/deviceType")
public class DeviceTypeController {
    @Autowired
    private DeviceTypeServer deviceServer;
    @GetMapping("/list")
    public MESResult list(DeviceType deviceType){
        System.out.println(deviceType.toString());
        return deviceServer.queryAll(deviceType);
    }
    @GetMapping("/childrenList")
    public MESResult childrenList(DeviceType deviceType){
        return deviceServer.queryChildrenByParentId(deviceType);
    }

    @GetMapping("/allOptions")
    public MESResult getOptions(){
        return deviceServer.getAllSelectionOptions();
    }
    @GetMapping("/updateSearch")
    public MESResult getUpdateSearch(String deviceTypeId){
        return deviceServer.queryByDeviceTypeId(deviceTypeId);
    }
    @PutMapping("/update")
    public MESResult updateDevice(@RequestBody DeviceType deviceType){
        return deviceServer.updateDeviceType(deviceType);
    }
    @PostMapping("/add")
    public MESResult add(@RequestBody DeviceType deviceType){
        return deviceServer.addNewDeviceType(deviceType);
    }
    @DeleteMapping("/delete")
    public MESResult delete(String deviceTypeId){
        return deviceServer.deleteDeviceType(deviceTypeId);
    }
}
